# Copyright (C) 2024-2025  Sutou Kouhei <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

ARG ALPINE_LINUX_VERSION
FROM alpine:${ALPINE_LINUX_VERSION}

RUN \
  apk --no-cache add \
    bash \
    bison \
    blas-dev \
    blosc-dev \
    bsd-compat-headers \
    ca-certificates \
    ccache \
    cmake \
    curl \
    g++ \
    gcc \
    gdb \
    git \
    lapack-dev \
    libedit-dev \
    libevent-dev \
    libstemmer-dev \
    lz4-dev \
    make \
    msgpack-c-dev \
    musl-dev \
    openssl-dev \
    pkgconf \
    rapidjson-dev \
    ruby-dev \
    samurai \
    # simdjson-dev \
    sudo \
    tzdata \
    xsimd-dev \
    xxhash-dev \
    zeromq-dev \
    zlib-dev \
    zstd-dev && \
    update-ca-certificates

RUN \
  gem install \
    bundler \
    grntest \
    groonga-client \
    pkg-config \
    rake

RUN \
  password=$(base64 /dev/random | head -c16) && \
  (echo ${password}; echo ${password}) | adduser groonga

RUN \
  echo "groonga ALL=(ALL:ALL) NOPASSWD:ALL" | \
    EDITOR=tee visudo -f /etc/sudoers.d/groonga

USER groonga
WORKDIR /home/groonga
